<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>解决Promise类then函数返回类型处理</title>
  <script src="./promise.js"></script>
</head>
<body>
  <script>
    const promise = new MyPromise((resolve, reject) => {
      // resolve('success')
      reject('fail')
    })
    MyPromise.resolve('success').then(res => console.log(res), err => console.log(err))
    MyPromise.resolve(promise).then(res => console.log(res), err => console.log(err))
    MyPromise.reject('fail').then(null, err => console.log(err))
  </script>
</body>
</html>